home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Mac F2C 1.2.2 / Test Project ƒ / main.cp < prev    next >
Encoding:
Text File  |  1995-05-13  |  2.6 KB  |  146 lines  |  [TEXT/KAHL]

  1. /* STARTUP PROCEDURE FOR UNIX FORTRAN PROGRAMS */
  2.  
  3. #include "stdio.h"
  4. #include "signal.h"
  5.  
  6. #ifndef SIGIOT
  7. #ifdef SIGABRT
  8. #define SIGIOT SIGABRT
  9. #endif
  10. #endif
  11.  
  12. #if defined(THINK_C) || defined(THINK_CPLUS) || defined(SYMANTEC_C) || defined(SYMANTEC_CPLUS)
  13. #include <console.h>    /* IMT 2 Dec 94 Needed to make command line work under THINK */
  14. #endif                    /* IMT 11 Apr 95 Modified to work under Symantec */
  15.  
  16. #ifdef __MWERKS__        /* IMT 2 Dec 94 Needed for MetroWerks (from Dirk Froehling) */
  17. #include <console.h>
  18. #include <SIOUX.h>
  19. #endif
  20.  
  21. #ifndef KR_headers
  22. #include "stdlib.h"
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. #ifdef NO__STDC
  29. #define ONEXIT onexit
  30. extern void f_exit();
  31. #else
  32. #ifndef KR_headers
  33. extern void f_exit(void);
  34. #ifndef NO_ONEXIT
  35. #define ONEXIT atexit
  36. extern int atexit(void (*)(void));
  37. #endif
  38. #else
  39. #ifndef NO_ONEXIT
  40. #define ONEXIT onexit
  41. extern void f_exit();
  42. #endif
  43. #endif
  44. #endif
  45.  
  46. #ifdef KR_headers
  47. extern void f_init(), sig_die();
  48. extern int MAIN__();
  49. #define Int /* int */
  50. #else
  51. extern void f_init(void), sig_die(char*, int);
  52. extern int MAIN__(void);
  53. #define Int int
  54. #endif
  55.  
  56. static void sigfdie(Int n)
  57. {
  58. sig_die("Floating Exception", 1);
  59. }
  60.  
  61.  
  62. static void sigidie(Int n)
  63. {
  64. sig_die("IOT Trap", 1);
  65. }
  66.  
  67. #ifdef SIGQUIT
  68. static void sigqdie(Int n)
  69. {
  70. sig_die("Quit signal", 1);
  71. }
  72. #endif
  73.  
  74.  
  75. static void sigindie(Int n)
  76. {
  77. sig_die("Interrupt", 0);
  78. }
  79.  
  80. static void sigtdie(Int n)
  81. {
  82. sig_die("Killed", 0);
  83. }
  84.  
  85. #ifdef SIGTRAP
  86. static void sigtrdie(Int n)
  87. {
  88. sig_die("Trace trap", 1);
  89. }
  90. #endif
  91.  
  92.  
  93.  
  94. int xargc;
  95. char **xargv;
  96.  
  97. #ifdef KR_headers
  98. main(argc, argv) int argc; char **argv;
  99. #else
  100. main(int argc, char **argv)
  101. #endif
  102. {
  103.  
  104. #if defined(THINK_C) || defined(THINK_CPLUS) || defined(SYMANTEC_C) || defined(SYMANTEC_CPLUS) || defined(__MWERKS__)
  105.  
  106.     argc = ccommand( &argv );        /* IMT 2 Dec 94 Think/Codewarrior mod; 11 May 95 Symantec mod */
  107.  
  108. #endif /* Macintosh C compilers */
  109.  
  110. xargc = argc;
  111. xargv = argv;
  112. signal(SIGFPE, sigfdie);    /* ignore underflow, enable overflow */
  113. #ifdef SIGIOT
  114. signal(SIGIOT, sigidie);
  115. #endif
  116. #ifdef SIGTRAP
  117. signal(SIGTRAP, sigtrdie);
  118. #endif
  119. #ifdef SIGQUIT
  120. if(signal(SIGQUIT,sigqdie) == SIG_IGN)
  121.     signal(SIGQUIT, SIG_IGN);
  122. #endif
  123. if(signal(SIGINT, sigindie) == SIG_IGN)
  124.     signal(SIGINT, SIG_IGN);
  125. signal(SIGTERM,sigtdie);
  126.  
  127. #ifdef pdp11
  128.     ldfps(01200); /* detect overflow as an exception */
  129. #endif
  130.  
  131. f_init();
  132. #ifndef NO_ONEXIT
  133. ONEXIT(f_exit);
  134. #endif
  135. MAIN__();
  136. #ifdef NO_ONEXIT
  137. f_exit();
  138. #endif
  139. exit(0);    /* exit(0) rather than return(0) to bypass Cray bug */
  140. return 0;    /* For compilers that complain of missing return values; */
  141.         /* others will complain that this is unreachable code. */
  142. }
  143. #ifdef __cplusplus
  144.     }
  145. #endif
  146.